import cv2

# 读取图像
image = cv2.imread('example.jpg')

# 将图像从BGR转换为YUV
yuv_image = cv2.cvtColor(image, cv2.COLOR_BGR2YUV)

# 保存YUV图像
cv2.imwrite('yuv_image.jpg', yuv_image)